home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performCopyKeyArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  11.4 KB  |  407 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  August 14, 1996
  22. //
  23. //  Description:
  24. //      This is a helper script to perfrom the copyKey command
  25. //    using the various options that have been set
  26. //
  27. //  Input Arguments:
  28. //        int action        0 - just execute the command
  29. //                        1 - show the option box dialog
  30. //                        2 - return the drag command
  31. //
  32. //  Return Value:
  33. //      None.
  34. //
  35.  
  36. proc setOptionVars (int $forceFactorySettings)
  37. {
  38.     keySetOptionBoxCommon( { "copyKey", 
  39.                              "unknown",
  40.                              "setOptionVars", 
  41.                              $forceFactorySettings } );
  42.  
  43.     // -options
  44.     //
  45.     if ($forceFactorySettings || !`optionVar -exists copyKeyOption`) {
  46.         optionVar -stringValue copyKeyOption "keys";
  47.     }
  48.     // help images
  49.     //
  50.     if ($forceFactorySettings || !`optionVar -exists copyKeyHelpPictures`) {
  51.         optionVar -intValue copyKeyHelpPictures 0;
  52.     }
  53. }
  54.  
  55. global proc copyKeySetup (string $parent, string $selectionConnection, int $forceFactorySettings)
  56. {
  57.     // Retrieve the option settings
  58.     //
  59.     setOptionVars ($forceFactorySettings);
  60.  
  61.     setParent $parent;
  62.  
  63.     keySetOptionBoxCommon( { "copyKey", $selectionConnection, "setup" } );
  64.  
  65.     // -option
  66.     //
  67.     string $option = `optionVar -query copyKeyOption`;
  68.     if ($option == "keys") {
  69.         radioButtonGrp
  70.             -edit
  71.             -select 1
  72.             method;
  73.     }
  74.     else {
  75.         radioButtonGrp
  76.             -edit
  77.             -select 2
  78.             method;
  79.     }
  80.  
  81.     // help images
  82.     //
  83.     int $pictures = `optionVar -q copyKeyHelpPictures`;
  84.     checkBoxGrp -e -value1 $pictures helpPictures;
  85.  
  86.     // Now get all the dependent widgets in the right 
  87.     // enabled/disabled/collapsed/expanded state
  88.     //
  89.     copyKeyWidgetsEnable ($selectionConnection);
  90.     copyKeyHelpPictures;
  91. }
  92.  
  93. global proc copyKeyCallback(string $parent, int $doIt,
  94.                             string $selectionConnection, 
  95.                             int $fromGraphEditor, 
  96.                             int $performAction )
  97. {
  98.     setParent $parent;
  99.  
  100.     keySetOptionBoxCommon( { "copyKey", $selectionConnection, "callback" } );
  101.  
  102.     // -option
  103.     string $option;
  104.     if (`radioButtonGrp -query -select method` == 1) {
  105.         $option = "keys";
  106.     }
  107.     else {
  108.         $option = "curve";
  109.     }
  110.     optionVar -stringValue copyKeyOption $option;
  111.  
  112.     // help
  113.     //
  114.     int $pictures = `checkBoxGrp -query -value1 helpPictures`;
  115.     optionVar -intValue copyKeyHelpPictures $pictures;
  116.  
  117.     if( $doIt ) {
  118.         string $args[] = { (string) $performAction,
  119.                            $selectionConnection, 
  120.                            (string) $fromGraphEditor };
  121.  
  122.         performCopyKeyArgList 1 $args;
  123.         string $tmpCmd = "performCopyKeyArgList 1 {\"" + $performAction + "\", \"";
  124.         $tmpCmd += $selectionConnection + "\", \"";
  125.         $tmpCmd += $fromGraphEditor + "\"}";
  126.         addToRecentCommandQueue $tmpCmd "Copy Keys";
  127.     }
  128. }
  129.  
  130. global proc copyKeyHelpPictures ()
  131. {
  132.     int $doPictures = `checkBoxGrp -q -value1 helpPictures`;
  133.     if( $doPictures == 0 ) {
  134.         frameLayout -e -collapse yes methodPictureFrame;
  135.         return;
  136.     }
  137.  
  138.     int $method = `radioButtonGrp -q -select method`;
  139.  
  140.     string $methodPicture;
  141.  
  142.     if( $method == 1 ) {
  143.         $methodPicture = "CCPkeyframesOnly.xpm";
  144.     } else {
  145.         $methodPicture = "CCPcurveExact.xpm";
  146.     }
  147.  
  148.     picture -e -image $methodPicture methodPicture;
  149.     frameLayout -e -collapse no methodPictureFrame;
  150. }
  151.  
  152. global proc copyKeyDoSelectionChanged (string $selectionConnection)
  153. //
  154. // Description:
  155. //    Since timeRange is irrelevant when there are 
  156. //    picked keyframes, collapse the timeRangeFrame
  157. //    when there are.  (This is hooked in to a SelectionChanged
  158. //    trigger.)
  159. //    
  160. {
  161.     keySetOptionBoxCommon( { "copyKey", $selectionConnection, "selectionChanged" } );
  162.  
  163.     if( `keyframe -q -sl -kc` > 0) {
  164.         radioButtonGrp -e -enable2 false -select 1 method;
  165.     } else {
  166.         //    Only enable the radioButtonGrp if the frame is enabled, otherwise
  167.         //    this proc will interfere with the copyKeyWidgetsEnable proc
  168.         //
  169.         if (`frameLayout -q -enable optionsFrame` == 1) {
  170.             radioButtonGrp -e -enable2 true method;
  171.         }
  172.     }
  173. }
  174.  
  175.  
  176. global proc copyKeyWidgetsEnable (string $selectionConnection)
  177. //
  178. // Description:
  179. //    These are the widgets that get enabled and
  180. //    disabled based on the certain states.  Put them
  181. //    here so they're all in one place.
  182. //    
  183. {
  184.     keySetOptionBoxCommon( { "copyKey", $selectionConnection, "enable" } );
  185.  
  186.     // Options frame
  187.     //
  188.     int $enableIt = ( `radioButtonGrp -q -select timeRange` != 1 );
  189.     frameLayout -e -enable $enableIt optionsFrame;
  190. }
  191.  
  192. proc string copyKeyWidgets( string $tabLayout, string $selectionConnection, int $fromGraphEditor )
  193. {
  194.     global int $gOptionBoxTextColumnWidthIndex;
  195.  
  196.     setParent $tabLayout;
  197.  
  198.     string $tabForm = `columnLayout -adjustableColumn true`;
  199.  
  200.     keySetOptionBoxCommon( { "copyKey", $selectionConnection, "widgets", $fromGraphEditor } );
  201.  
  202.     frameLayout -bv no -lv no -collapsable no optionsFrame;
  203.         columnLayout -adjustableColumn true;
  204.  
  205.             checkBoxGrp -label "Help Images" -ncb 1 -value1 off -l1 "" 
  206.                 -cc1 "copyKeyHelpPictures;" 
  207.                 helpPictures;
  208.  
  209.             radioButtonGrp -numberOfRadioButtons 2 -label "Method" 
  210.                 -label1 "Keys" -cc1 "copyKeyHelpPictures"
  211.                 -label2 "Segments" -cc2 "copyKeyHelpPictures" method;
  212.  
  213.             frameLayout -bv no -lv no -collapsable yes -collapse yes 
  214.                 methodPictureFrame;
  215.  
  216.                 columnLayout -columnAttach "left" 
  217.                     $gOptionBoxTextColumnWidthIndex;
  218.  
  219.                     picture methodPicture;
  220.  
  221.                     setParent ..;
  222.                 setParent ..;
  223.                 
  224.             setParent ..;
  225.  
  226.         setParent ..;
  227.  
  228.     return $tabForm;
  229. }
  230.  
  231. proc copyKeyOptions( string $selectionConnection, int $performAction, int $fromGraphEditor )
  232. {
  233.     // Customisation options
  234.     //
  235.     // Name of the command for this option box (think of it as the base class)
  236.     string $commandName = "copyKey";
  237.     // Title for the option box window
  238.     string $optionBoxTitle = "Copy Keys Options";
  239.     // Title for the apply button
  240.     string $applyTitle = "Copy keys";
  241.  
  242.     // Build the option box "methods"
  243.     //
  244.     string $callback = ($commandName + "Callback");
  245.     string $setup = ($commandName + "Setup");
  246.  
  247.     // Build the window, with a tab layout
  248.     //
  249.     string $widgetList[] = `getStandardWindow $optionBoxTitle 0 "noOptions"`;
  250.     setUITemplate -pushTemplate DefaultTemplate;
  251.  
  252.     // Make the form invisible while we create the widgets in the window
  253.     //
  254.     formLayout -e -vis false $widgetList[1];
  255.  
  256.     // Attach the widgets.  No tab layout needed.
  257.     //
  258.     copyKeyWidgets $widgetList[2] $selectionConnection $fromGraphEditor;
  259.  
  260.     // Attach the standard buttons
  261.     //
  262.     string $buttonList[] = `addStandardButtons $commandName $applyTitle 
  263.         $widgetList[1] $widgetList[2] "noOptions"`;
  264.  
  265.     // attach commands to the standard buttons
  266.     //
  267.     // Save
  268.     //
  269.     button -e -c ($callback + " " + $widgetList[0] + " false \"\" " + 
  270.                   $fromGraphEditor + " " + $performAction +
  271.                   "; hideOptionBox()") $buttonList[3];
  272.  
  273.     // Close
  274.     //
  275.     button -edit -command hideOptionBox $buttonList[2];
  276.  
  277.     // Reset
  278.     //
  279.     button -edit -command ($setup + " " + $widgetList[0] + " " + $selectionConnection + " true") 
  280.         $buttonList[1];
  281.  
  282.     // DoIt
  283.     //
  284.     button -edit -command ($callback + " " + $widgetList[0] + " true \"" + 
  285.                            $selectionConnection + "\" " + $fromGraphEditor + 
  286.                            " " + $performAction) $buttonList[0];
  287.  
  288.     // Make the form layout visible so we can see what we built, and
  289.     // reset the template
  290.     //
  291.     formLayout -e -vis true $widgetList[1];
  292.     setUITemplate -popTemplate;
  293.  
  294.     //    Customize the 'Help' menu item text.
  295.     //    This is called from 3 different places so look at the selection
  296.     //    connection to try to figure out which one.
  297.     //
  298.     if (match ("graphEditor", $selectionConnection) != "") {
  299.         setOptionBoxHelpTag( "GraphCopy" );
  300.     } else if (match ("dopeSheet", $selectionConnection) != "") {
  301.         setOptionBoxHelpTag( "DopeCopy" );
  302.     } else {
  303.         setOptionBoxHelpTag( "KeysCopyKeys" );
  304.     }
  305.  
  306.     // Call the setup "method" to fill in the current settings
  307.     //
  308.     eval (($setup + " " + $widgetList[0] + " " + $selectionConnection + " false"));    
  309.     showOptionBox();
  310.     showWindow $widgetList[0];
  311.  
  312.     if( $fromGraphEditor ) {
  313.         copyKeyDoSelectionChanged($selectionConnection);    
  314.         scriptJob -protected
  315.             -event "SelectionChanged" ("copyKeyDoSelectionChanged " + $selectionConnection) 
  316.             -parent $widgetList[2];
  317.     }
  318. }
  319.  
  320. proc string assembleCmd( string $selectionConnection, 
  321.                          int $fromGraphEditor,
  322.                          string $options ) 
  323. {
  324.     // doCopyKeyArgList takes a string array
  325.     //
  326.     string $cmd = "doCopyKeyArgList 3 { " + 
  327.                 "\"" + `optionVar -q copyKeyWhichRange` + "\"" + 
  328.                 ",\"" + `optionVar -q copyKeyRange` + "\"" + 
  329.                 ",\"" + `optionVar -q copyKeyOption` + "\"" + 
  330.                 ",\"" + `optionVar -q copyKeyHierarchy` + "\"" + 
  331.                 ",\"" + `optionVar -q copyKeyControlPoints` + "\"" + 
  332.                 ",\"" + `optionVar -q copyKeyShapes` + "\"" + 
  333.                 ",\"" + `optionVar -q copyKeyUseChannelBox` + "\"" + 
  334.                 ",\"" + $selectionConnection + "\"" + 
  335.                 ",\"" + $options + "\"" + 
  336.                 ",\"" + $fromGraphEditor + "\"" +
  337.                 ",\"" + `optionVar -q copyKeyDriven` + "\"" +
  338.             " };";        
  339.  
  340.     return $cmd;
  341. }
  342.  
  343. global proc string performCopyKeyArgList (string $version, string $args[])
  344. //
  345. //  Input Arguments:
  346. //    $version: The version of this option box.  Used to know how to 
  347. //    interpret the $args array.
  348. //        "1" : $action, $selectionConnection, $fromGraphEditor
  349. //
  350. //    $args
  351. //    Version 1
  352. //    [0]        $action                    0 - do the command
  353. //                                    1 - show the option box
  354. //                                    2 - return the drag command
  355. //                                    3 - do the command (bufferCurve version)
  356. //                                    4 - show the option box (bufferCurve version)
  357. //                                    5 - return the drag command (bufferCurve version)
  358. //    [1]        $selectionConnection    name of selection connection to use
  359. //                                    unless $options has "bufferCurve" in which
  360. //                                    case this is the name of the editor
  361. //    [2]        $fromGraphEditor        true if being called from the graph editor
  362. //
  363. //  Return Value:
  364. //      The actual command to execute.
  365. //
  366. {
  367.     int        $versionNum                = $version;
  368.  
  369.     int        $action                    = $args[0];
  370.     string    $selectionConnection    = $args[1];
  371.     int        $fromGraphEditor        = $args[2];
  372.  
  373.     string $cmd = "";
  374.  
  375.     switch( $action ) {
  376.     case 0:
  377.         setOptionVars( false );
  378.         $cmd = assembleCmd( $selectionConnection, $fromGraphEditor, 
  379.                             "noOptions" );
  380.         eval( $cmd );
  381.         break;
  382.     case 1:
  383.         copyKeyOptions( $selectionConnection, 0, $fromGraphEditor );
  384.         break;
  385.     case 2:
  386.         setOptionVars( false );
  387.         $cmd = assembleCmd( $selectionConnection, $fromGraphEditor, 
  388.                             "noOptions" );
  389.         break;
  390.     case 3:
  391.         setOptionVars( false );
  392.         $cmd = assembleCmd( $selectionConnection, $fromGraphEditor, 
  393.                             "bufferCurve" );
  394.         eval( $cmd );
  395.         break;
  396.     case 4:
  397.         copyKeyOptions( $selectionConnection, 3, $fromGraphEditor );
  398.         break;
  399.     case 5:
  400.         setOptionVars( false );
  401.         $cmd = assembleCmd( $selectionConnection, $fromGraphEditor, 
  402.                             "bufferCurve" );
  403.         break;
  404.     }
  405.     return ($cmd);
  406. }
  407.